package org.sgx.gapi.client.apis.tasks.tasklists;

import org.sgx.gapi.client.GAPI;
import org.sgx.gapi.client.client.ClientRequest;
import org.sgx.gapi.client.client.ClientRequestCallback;
import org.sgx.gapi.client.client.GAPICallback;
import org.sgx.gapi.client.client.GAPIListRequest;
import org.sgx.gapi.client.client.GAPIResult;
import org.sgx.gapi.client.client.HttpRequest;
import org.sgx.jsutil.client.JsObject;

/**
 * Returns all the authenticated user's task lists
 * @see https://developers.google.com/google-apps/tasks/v1/reference/tasklists/list
 * @author sg
 * 
 */
public class ListRequest
extends GAPIListRequest<ListResponse> {
	
	@Override
	public void execute(final GAPICallback<ListResponse> c) {
		JsObject param = getListParams();
		ClientRequest clientReq = ClientRequest.create()
				.path("/tasks/v1/users/@me/lists")
				.params(param);
		HttpRequest req = GAPI.get().client().request(clientReq);
		req.execute(new ClientRequestCallback() {
			@Override
			public void call(GAPIResult jsonResp, String rawResp) {
				c.call((ListResponse) jsonResp.cast());
			}
		});
	}

}
